package com.nfit.shopadmin.controller;

import com.nfit.shopadmin.service.FileUploadService;
import com.nfit.shopmodel.vo.common.Result;
import com.nfit.shopmodel.vo.common.ResultCodeEnum;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * ClassName:fileUploadController
 * Package:com.nfit.shopadmin.controller
 * Description
 *
 * @Author L
 * @Create 2024/12/28 22:27
 */
@Tag(name = "minio",description = "文件上传控制器")
@RestController
@RequestMapping("/admin/minio")
public class fileUploadController {

    @Autowired
    private FileUploadService fileUploadService;

    /**
     * minio文件上传
     * <input type="file" name="file" />
     * @param file 路径
     */
    @PostMapping(value = "/fileUpload")
    public Result uploadFile(@RequestParam(value = "file") MultipartFile file) {
        //获取service的方法上传，返回minio路径
        String fileURL = fileUploadService.fileUpload(file);
        return Result.build(fileURL, ResultCodeEnum.SUCCESS);
    }

}
